<?php
/**
 * This file is part of the Jindai.
 * @copyright Copyright (c) 2019 All Rights Reserved.
 * @author jindai <jindai0305@gmail.com>
 */

namespace App\Http\Controllers\Api\v1\Admin;


use App\Http\Controllers\Api\v1\Controller;
use App\Repositories\MusicRepository;
use Illuminate\Http\Request;

/**
 * Class MusicController
 * @package App\Http\Controllers\Api\v1
 *
 * @SWG\Tag(name="Admin - Music", description="后台歌曲")
 */
class MusicController extends Controller
{
    /**
     * @inheritdoc
     */
    public function __construct(MusicRepository $model)
    {
        parent::__construct();
        $this->model = $model;
    }

    /**
     * @param Request $request
     * @return mixed|\Psr\Http\Message\ResponseInterface|string
     * @throws \GuzzleHttp\Exception\GuzzleException
     *
     * @SWG\Get(path="/admin/music/search",
     *     tags={"Admin - Music"},
     *     description="搜索歌曲列表",
     *     produces={"application/json"},
     *     @SWG\Parameter(in="query", name="q", type="string", description="搜索内容 按标题", required=true),
     *     @SWG\Parameter(ref="#/parameters/offsetPageParam"),
     *     @SWG\Parameter(ref="#/parameters/offsetLimitParam"),
     *     @SWG\Response(response=200, description="success"),
     *     @SWG\Response(response=400,description="failed"),
     *     @SWG\Response(response=401, description="未登录")
     * )
     */
    public function search(Request $request)
    {
        return [
            'data' => $this->model->search($request),
            'meta' => $this->model->getMeta()
        ];
    }
}
